﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RMS.Utils.MVP;
using RMS.DataAccess.Repositories;
using RMS.DataAccess.Entities;
using RMS.Web.Shell.View;
using RMS.Utils.Authentication;
using RMS.DataAccess.Common;

namespace RMS.Web.Shell.Presenter
{
    public class RequestDetailsPresenter : Presenter<IRequestDetailsView>
    {
        TechnicianRadiologyRequestsDtoRepository _technicianRadiologyRequestDtoRepository;
        RadiologyRequestRepository _radiologyRequestRepository;
        IAuthentication _authentication;
        public RequestDetailsPresenter(TechnicianRadiologyRequestsDtoRepository technicianRadiologyRequestDtoRepository,
            RadiologyRequestRepository radiologyRequestRepository, IAuthentication authentication)
        {
            _technicianRadiologyRequestDtoRepository = technicianRadiologyRequestDtoRepository;
            _radiologyRequestRepository = radiologyRequestRepository;
            _authentication = authentication;
        }


        public TechnicianRadiologyRequestsDto CurrentRequest(int RequestID)
        {
            try
            {
                return _technicianRadiologyRequestDtoRepository.Find(item =>
                {
                    item.TechnicianID = _authentication.CurrentLogedInMember.Id;
                    item.RequestId = RequestID;
                }).Single();
            }
            catch
            { 
      return  new TechnicianRadiologyRequestsDto();
            }
        }


    }
}
